package org.xlx.xlx_oa.role_user.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xlx.xlx_oa.common.ResponseBean;
import org.xlx.xlx_oa.role_user.api.SysRoleApi;
import org.xlx.xlx_oa.role_user.domain.vo.SysRoleVo;
import org.xlx.xlx_oa.role_user.service.SysRoleService;

@RestController
@RequestMapping("/v1/sys-role")
public class SysRoleController implements SysRoleApi {
    @Autowired
    private SysRoleService sysRoleService;

    @PostMapping("/save")
    @Override
    public ResponseBean saveEntity(@RequestBody SysRoleVo vo) {
        return ResponseBean.successFactory(sysRoleService.saveEntity(vo));
    }

    @GetMapping("/remove/{id}")
    @Override
    public ResponseBean removeEntity(@PathVariable(value = "id") Long id) {
        return ResponseBean.successFactory(sysRoleService.removeEntity(id));
    }

    @PostMapping("/list")
    @Override
    public ResponseBean getList(@RequestBody SysRoleVo vo) {
        return ResponseBean.successFactory(sysRoleService.getList(vo));
    }

    @GetMapping("/detail/{id}")
    @Override
    public ResponseBean getDetail(@PathVariable(value = "id") Long id) {
        return ResponseBean.successFactory(sysRoleService.getDetail(id));
    }

    @GetMapping("/check/{id}")
    @Override
    public ResponseBean checkAdmin() {
        return ResponseBean.successFactory(sysRoleService.isAdmin());
    }
}

